package com.ruoyi.service.basic.impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.basic.MesMaterial;
import com.ruoyi.mapper.basic.MesMaterialMapper;
import com.ruoyi.service.basic.IMesMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 物料信息Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class MesMaterialServiceImpl implements IMesMaterialService
{
    @Autowired
    private MesMaterialMapper mesMaterialMapper;

    /**
     * 查询物料信息
     * 
     * @param materialId 物料信息主键
     * @return 物料信息
     */
    @Override
    public MesMaterial selectMesMaterialByMaterialId(Long materialId)
    {
        return mesMaterialMapper.selectMesMaterialByMaterialId(materialId);
    }

    /**
     * 查询物料信息列表
     * 
     * @param mesMaterial 物料信息
     * @return 物料信息
     */
    @Override
    public List<MesMaterial> selectMesMaterialList(MesMaterial mesMaterial)
    {
        return mesMaterialMapper.selectMesMaterialList(mesMaterial);
    }

    /**
     * 新增物料信息
     * 
     * @param mesMaterial 物料信息
     * @return 结果
     */
    @Override
    public int insertMesMaterial(MesMaterial mesMaterial)
    {
        return mesMaterialMapper.insertMesMaterial(mesMaterial);
    }

    /**
     * 修改物料信息
     * 
     * @param mesMaterial 物料信息
     * @return 结果
     */
    @Override
    public int updateMesMaterial(MesMaterial mesMaterial)
    {
        return mesMaterialMapper.updateMesMaterial(mesMaterial);
    }

    /**
     * 批量删除物料信息
     * 
     * @param materialIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int deleteMesMaterialByMaterialIds(Long[] materialIds)
    {
        return mesMaterialMapper.deleteMesMaterialByMaterialIds(materialIds);
    }

    /**
     * 删除物料信息信息
     * 
     * @param materialId 物料信息主键
     * @return 结果
     */
    @Override
    public int deleteMesMaterialByMaterialId(Long materialId)
    {
        return mesMaterialMapper.deleteMesMaterialByMaterialId(materialId);
    }

    /**
     * 校验物料编码是否唯一
     * 
     * @param materialCode 物料编码
     * @return 结果
     */
    @Override
    public String checkMaterialCodeUnique(String materialCode)
    {
        MesMaterial material = mesMaterialMapper.checkMaterialCodeUnique(materialCode);
        if (StringUtils.isNotNull(material))
        {
            return "1";
        }
        return "0";
    }
}